/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import pojos.Employees;

/**
 *
 * @author A7med Kotb
 */
@Stateless
public class EmployeesFacade extends AbstractFacade<Employees> {

    @PersistenceContext(unitName = "AquantimaISPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public EmployeesFacade() {
        super(Employees.class);
    }

    public Employees checkUserLogin(String userName, String pass) {
        try {
            Query query = getEntityManager().createNamedQuery("Employees.findByBusinessEmail&Password");
            query.setParameter("businessEmail", userName);
            query.setParameter("password", pass);
            return (Employees) query.getSingleResult();
        } catch (Exception ex) {
            return null;
        }
    }
}
